home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1987 / MacApp Bugs
Encoding:
Text File  |  1991-03-06  |  8.0 KB  |  393 lines  |  [TEXT/MPS ]

  1.  
  2. Dear MacApp developers,
  3.  
  4.     In my use of MacApp version 2.0b5 I have run across several bugs/dislikes.  Some
  5. of the problems are serious, so I felt that I should send this in now.
  6.  
  7.     Some of the problems I have found so far are only potential problems, such as the
  8. under-use of the failure mechanism, but I think they should be addressed system wide.
  9. You can't assume that methods which may be overridden will never fail.  Obviously,
  10. I hope you agree with my reasoning.
  11.  
  12.     I hope this helps.  Let me know if you need any more information.
  13.  
  14. Gary L. Bringhurst
  15. Strata
  16.  
  17.  
  18. ---------
  19.  
  20. Affected/fixed routines follow:
  21.  
  22.  
  23.  
  24. PROCEDURE TRadio.DoChoice(origView: TView; itsChoice: INTEGER);
  25. BEGIN
  26. (*
  27. **    Modified to pass on the itsChoice message.  The original design decision was wrong,
  28. **    while the comment was right.  Subclasses of TRadio may want the itsChoice message
  29. **    to travel up the view hierarchy.  (mine do)
  30. **    Changed 11/2/88 by GLB.
  31. *)
  32. {$IFC False}
  33.     IF (itsChoice = mRadioHit) & NOT IsOn THEN
  34.         BEGIN
  35.         Toggle(kRedraw);
  36.         INHERITED DoChoice(origView, itsChoice);    { Should this be called regardless??? }
  37.         END;
  38. {$ELSEC}
  39.     IF (itsChoice = mRadioHit) & NOT IsOn THEN
  40.         Toggle(kRedraw);
  41.     INHERITED DoChoice(origView, itsChoice);
  42. {$ENDC}
  43. END;
  44.  
  45.  
  46.  
  47. FUNCTION  TCluster.ReportCurrent: IDType;
  48. VAR
  49.     rView:        TView;
  50.  
  51.     {-------------------------------+
  52.     |    FindRadio                    |
  53.     +-------------------------------}
  54.     FUNCTION  FindRadio(aView: TView): BOOLEAN;
  55.     BEGIN
  56. (*
  57. **    This test MUST be a short-circuit test, in case the view is NOT TRadio!
  58. **    Modified 11/1/88 by GLB.
  59. *)
  60. {$IFC False}
  61.         FindRadio := MEMBER(aView, TRadio) AND TRadio(aView).IsOn;
  62. {$ELSEC}
  63.         FindRadio := MEMBER(aView, TRadio) & TRadio(aView).IsOn;
  64. {$ENDC}
  65.     END;
  66.  
  67. BEGIN
  68.     rView := FirstSubViewThat(FindRadio);
  69.     IF rView <> NIL THEN
  70.         ReportCurrent := rView.fIdentifier
  71.     ELSE
  72.         ReportCurrent := kNoIdentifier;
  73. END;
  74.  
  75.  
  76.  
  77. PROCEDURE TPicture.Draw (area: Rect); OVERRIDE;
  78. VAR
  79.     oldState:        SignedByte;
  80.     theRect:        Rect;
  81.  
  82. BEGIN
  83.     IF fDataHandle <> NIL THEN
  84.         BEGIN
  85.         ControlArea(theRect);
  86.         IF fRsrcID <> kNoResource THEN
  87.             LoadResource(Handle(fDataHandle));
  88. (*
  89. **    This doesn't make any sense!  We know that fDataHandle <> NIL.  What we don't know
  90. **    is if it's empty, even after the (potential) LoadResource call above.
  91. **    Changed 11/2/88 by GLB.
  92. *)
  93. {$IFC False}
  94.         IF fDataHandle = NIL THEN
  95. {$ELSEC}
  96.         IF fDataHandle^ = NIL THEN
  97. {$ENDC}
  98.             ReleasePicture                                { Isn't this a little harsh???    }
  99.         ELSE
  100.             BEGIN
  101.             oldState := GetHandleBits(Handle(fDataHandle));
  102.             HNoPurge(Handle(fDataHandle));
  103.             PenNormal; { ??? NECESSARY ??? }
  104.             DrawPicture(fDataHandle, theRect);
  105.             SetHandleBits(Handle(fDataHandle), oldState);
  106.             END;
  107.         END;
  108.     INHERITED Draw(area);
  109. END;
  110.  
  111.  
  112.  
  113. FUNCTION  ParseTitleTemplate(VAR template: Str255; VAR preDocname, constTitle: INTEGER): BOOLEAN;
  114.  
  115. ...
  116.  
  117. {$IFC False}
  118.     FUNCTION FindPos (pattern: Str255; VAR source: Str255): INTEGER;
  119. {$ELSEC}
  120.     FUNCTION FindPos (pattern: Str255;  source: Str255): INTEGER;
  121. {$ENDC}
  122.     VAR
  123.         position:    INTEGER;
  124.     BEGIN
  125. (*
  126. **    What good does this crap do???  It will repeat forever unless some change is
  127. **    made after CharByte fails!  (It also calls even though position = 0)
  128. *)
  129. {$IFC False}
  130.         IF gConfiguration.hasScriptManager THEN
  131.             REPEAT
  132.                 position := POS(pattern, source);
  133.             UNTIL (position = 0) OR (CharByte(@source, position) = 0)
  134. {$ELSEC}
  135.         { This bug fix added 11/1/88 by GLB    }
  136.         IF gConfiguration.hasScriptManager THEN
  137.             WHILE True DO BEGIN
  138.                 position := POS(pattern, source);
  139.                 IF (position = 0) | (CharByte(@source, position) = 0) THEN
  140.                     Leave;
  141.                 REPEAT
  142.                     position:= position + 1;
  143.                 UNTIL CharByte(@source, position) <= 0;
  144.                 Delete(source, 1, position - 1);
  145.             END
  146. {$ENDC}
  147.         ELSE
  148.             position := POS(pattern, source);
  149.         FindPos := position;
  150.     END;
  151.  
  152. BEGIN
  153.  
  154. ...
  155.  
  156. END;
  157.  
  158.  
  159.  
  160. FUNCTION  TApplication.TrackCursor: BOOLEAN;
  161.  
  162. ...
  163.  
  164. BEGIN
  165.  
  166. ...
  167.  
  168.     IF (FindWindow(globalMouse, aWMgrWindow) = inContent) THEN
  169.         BEGIN
  170.         { The cursor is in a window--for our purposes, it must be the front
  171.             window or the window must handle first clicks }
  172.         cursorWindow := WMgrToWindow(aWMgrWindow);
  173. (*
  174. **    BUG!    Repaired 10/31/88 by GLB
  175. *)
  176.         IF {Added} (cursorWindow <> NIL) {Done} &
  177.                     (cursorWindow <> gFrontWindow) & (NOT cursorWindow.fDoFirstClick) THEN
  178.             cursorWindow := NIL;
  179.         END
  180.     ELSE
  181.         cursorWindow := NIL;
  182.  
  183. ...
  184.  
  185. END;
  186.  
  187.  
  188.  
  189. PROCEDURE TView.DrawContents;
  190. VAR
  191.  
  192. ...
  193.  
  194.     fi:                    FailInfo;
  195.     
  196.     
  197.     PROCEDURE HdlTVDCFail(error: OSErr;  message: Longint);
  198.     BEGIN
  199.         DisposeRgn(savedClip);
  200.     END;  { HdlTVDCFail }
  201.     
  202. ...
  203.  
  204. BEGIN
  205.     IF Focus THEN
  206.         BEGIN
  207.  
  208. ...
  209.  
  210.         IF (NOT displaying) | SectRect(visRect, thePort^.visRgn^^.rgnbBox, visRect) THEN
  211.             BEGIN
  212.  
  213. ...
  214.             
  215.             (*
  216.             **    Please, oh please, use the failure mechanism to ensure that we don't
  217.             **    leave here without disposing of our temporary region!
  218.             **    Changed 11/8/88 by GLB.
  219.             *)
  220.             IF CountSubViews > 0 THEN
  221.                 BEGIN
  222.                 longOffset := gLongOffset;
  223.                 savedClip := MakeNewRgn;                { Save the superview's focus.        }
  224.                 
  225. { *** }            CatchFailures(fi, HdlTVDCFail);
  226.                 
  227.                 savedOrigin := thePort^.portRect.topLeft;
  228.                 savedLongOffset := gLongOffset;
  229.                 GetClip(savedClip);
  230.                 EachSubView(DrawSubView);
  231.                 
  232. { *** }            Success(fi);
  233.                 
  234.                 DisposeRgn(savedClip);
  235.                 END;
  236.             END;
  237.         END;
  238. END {TView.DrawContents};
  239.  
  240.  
  241.  
  242. PROCEDURE TView.LocalToWindow (VAR thePoint: VPoint);
  243.  
  244. VAR
  245.     aView:        TView;
  246.  
  247. BEGIN
  248.     aView := SELF;
  249.     (*
  250.     **    The existing algorithm changes from local to global coordinates.
  251.     **    (if we are actually in a window)
  252.     **    Changed 11/7/88 by GLB.
  253.     *)
  254. {$IFC False}
  255.     WHILE aView <> NIL DO
  256. {$ELSEC}
  257.     WHILE aView.fSuperView <> NIL DO
  258. {$ENDC}
  259.         BEGIN
  260.         AddVPt(aView.fLocation, thePoint);
  261.         aView := aView.fSuperView;
  262.         END;
  263. END {TView.LocalToWindow};
  264.  
  265.  
  266.  
  267. PROCEDURE TView.WindowToLocal (VAR thePoint: VPoint);
  268.  
  269. VAR
  270.     aView:        TView;
  271.  
  272. BEGIN
  273.     aView := SELF;
  274.     (*
  275.     **    The existing algorithm changes from global to local coordinates.
  276.     **    (if we are actually in a window)
  277.     **    Changed 11/7/88 by GLB.
  278.     *)
  279. {$IFC False}
  280.     WHILE aView <> NIL DO
  281. {$ELSEC}
  282.     WHILE aView.fSuperView <> NIL DO
  283. {$ENDC}
  284.         BEGIN
  285.         SubVPt(aView.fLocation, thePoint);
  286.         aView := aView.fSuperView;
  287.         END;
  288. END {TView.WindowToLocal};
  289.  
  290.  
  291.  
  292. (*
  293. **    I didn't mark carefully all of the changes to this method.  If you agree with me that
  294. **    it needs fixing you'll have to do a comparison with the original to find all of my 
  295. **    changes.
  296. *)
  297.  
  298. PROCEDURE TView.WriteToDeskScrap;
  299. VAR
  300.     pHndl:        PicHandle;
  301.     picOpen:    Boolean;
  302.     qdExtent:     Rect;
  303.     err:        LONGINT;
  304.     tempPort:    GrafPort;
  305.     tempCPort:    CGrafPort;
  306.     fi:            FailInfo;
  307.     
  308.     
  309.     (*
  310.     **    This method MUST catch any failures in order to ensure nothing is left
  311.     **    dangling!
  312.     **    Fixed 11/5/88 by GLB.
  313.     *)
  314.     PROCEDURE HdlTVWTDSFail(error: OSErr;  message: Longint);
  315.     BEGIN
  316.         IF pHndl <> NIL THEN BEGIN
  317.             IF gDrawingPictScrap THEN BEGIN
  318.                 ClosePicture;
  319.                 gDrawingPictScrap:= False;
  320.             END;
  321.             KillPicture(pHndl);
  322.         END;
  323.         IF gConfiguration.hasColorQD THEN
  324.             CloseCPort(@tempCPort)
  325.         ELSE
  326.             ClosePort(@tempPort);
  327.     END;  { HdlTVWTDSFail }
  328.     
  329.     
  330. BEGIN
  331.     GetQDExtent(qdExtent);
  332.  
  333.     IF gConfiguration.hasColorQD THEN
  334.         OpenCPort(@tempCPort)
  335.     ELSE
  336.         OpenPort(@tempPort);
  337.     
  338.     {Open color or black & white, depending on the port}
  339.     pHndl := OpenPicture(qdExtent);
  340.     
  341.     CatchFailures(fi, HdlTVWTDSFail);
  342.  
  343.     IF pHndl <> NIL THEN
  344.         BEGIN
  345.         gDrawingPictScrap := TRUE;
  346.         ClipRect(qdExtent);
  347.         
  348.         Draw(qdExtent);
  349.         
  350.         gDrawingPictScrap := FALSE;
  351.         ClosePicture;
  352.  
  353.         {On the 128K ROMs the picFrame will be empty if drawing the
  354.             picture failed.  On the 64K ROM's QuickDraw simply bombs.}
  355.         IF EmptyRect(pHndl^^.picFrame) THEN
  356.             BEGIN
  357. {$IFC qDebug}
  358.             WRITELN('Picture frame is empty!');
  359. {$ENDC}
  360.             KillPicture(pHndl);
  361.             pHndl:= NIL;
  362.             Failure(memFullErr, 0);
  363.             END;
  364.  
  365.         err := PutDeskScrapData('PICT', Handle(pHndl));
  366.         KillPicture(pHndl);
  367.         pHndl:= NIL;
  368.  
  369.         IF err <> NoErr THEN
  370.             BEGIN
  371. {$IFC qDebug}
  372.             ProgramBreak('Failed to put PICT-type scrap');
  373. {$ENDC}
  374.             Failure(err, 0);
  375.             END;
  376.         END
  377.     ELSE
  378.             BEGIN
  379. {$IFC qDebug}
  380.             ProgramBreak('Couldn''t 0penPicture during attempt to write PICT to desk scrap');
  381. {$ENDC}
  382.             Failure(memFullErr, 0);  {Assume cause of failure was lack of memory}
  383.             END;
  384.     
  385.     Success(fi);
  386.     
  387.     IF gConfiguration.hasColorQD THEN
  388.         CloseCPort(@tempCPort)
  389.     ELSE
  390.         ClosePort(@tempPort);
  391. END {TView.WriteToDeskScrap};
  392.  
  393.